package com.Exe;

import com.entity.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.nio.file.AccessDeniedException;

@ControllerAdvice
@ResponseBody
public class MyExceptionAdvice {
    @ExceptionHandler(Exception.class)
    public Result check(Exception e) {
        if (e instanceof AccessDeniedException){
            System.out.println("403来了...");
            return new Result(false,"没有权限操作");
        }else {
            return new Result(false,"未知错误");
        }

    }
}
